//
//  TRHomeSearchController.m
//  WeiMiLan
//
//  Created by Mac on 15/9/14.
//  Copyright (c) 2015年 Mac. All rights reserved.
//

#import "TRHomeSearchController.h"

@interface TRHomeSearchController ()

@end

@implementation TRHomeSearchController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self initNavigation];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)initNavigation
{
    [self.navigationController setNavigationBarHidden:YES animated:YES];
    self.weChatNavigationBar=[[WeChatNavigationBar alloc] init];
    self.weChatNavigationBar.height = 64;
    [self.view addSubview:self.weChatNavigationBar];
    //  self.weChatNavigationBar.titleLabel.text=@"搜索";
    //  [self.weChatNavigationBar.leftButton setBackgroundImage:@"" forState:UIControlStateNormal];
    [self.weChatNavigationBar.leftButton addTarget:self action:@selector(exit) forControlEvents:UIControlEventTouchUpInside];
    
    UISearchBar *searchBar = [[UISearchBar alloc]init];
    searchBar.frame = CGRectMake(CGRectGetMaxX(self.weChatNavigationBar.leftButton.frame), self.weChatNavigationBar.leftButton.frame.origin.y - 2, self.view.width *0.75, 32);
    searchBar.placeholder = @"搜做股票/基金/字母";
    searchBar.backgroundImage = [UIImage imageNamed:@"圆角矩形-home"];
    
    
    TRButton *cancelBtn = [TRButton buttonWithType:UIButtonTypeCustom];
    cancelBtn.frame = CGRectMake(CGRectGetMaxX(searchBar.frame), searchBar.frame.origin.y, 36, searchBar.height);
    [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [cancelBtn addTarget:self action:@selector(exit) forControlEvents:UIControlEventTouchUpInside];
    // NSLog(@"--------%@",NSStringFromCGRect(cancelBtn.frame));
    [cancelBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //cancelBtn.backgroundColor = [UIColor greenColor];
    cancelBtn.titleLabel.font = [UIFont systemFontOfSize:15.0];
    [self.weChatNavigationBar.contentViews addSubview:cancelBtn];
    
    [self.weChatNavigationBar.contentViews addSubview:searchBar];
    self.searchBar = searchBar;
   // self.searchBar.delegate = self;
    // [self.weChatNavigationBar.contentViews addSubview:segmented2];
    self.weChatNavigationBar.rightButton.hidden = YES;
    
}

-(void)exit
{
   // [self.navigationController popViewControllerAnimated:YES];
     [self dismissViewControllerAnimated:YES completion:nil];
}

@end
